import { DefaultTheme } from 'vitepress'
import { SidebarMulti } from 'vitepress/types/default-theme'
import * as path from 'node:path'


/**
 * elsfsCloud 文档
 */
const elsfsCloud: DefaultTheme.SidebarItem = {
  base: '/elsfsCloud',
  items: [
    {
      text: 'elsfs-cloud文档',
      items: [{
        text: '介绍',
        link: '/introduction'
      },
        {
          text: '环境准备',
          link: '/quick-start'
        },
        {
          text: '开发环境',
          items: [
            {
              text: 'jdk环境安装',
              link: '/development/jdk'
            },
            {
              text: 'maven环境安装',
              link: '/development/maven'
            },
            {
              text: 'gradle环境安装',
              link: '/development/gradle'
            },
            {
              text: 'mysql环境安装',
              link: '/development/mysql'
            },
            {
              text: 'nacos安装',
              link: '/development/nacos'
            },
            {
              text: 'redis安装',
              link: '/development/redis'
            }
          ]
        },
        {
          text: '系统模块',
          items: [
            {
              text: '数据E-R图',
              link: '/system/db_er'
            }
          ]
        },
        {
          text: '注解详解',
          items: [
            {
              text: '字典翻译',
              link: '/annotation/Dict'
            },
            {
              text: '字段脱敏注解',
              link: '/annotation/SensitiveBye'
            },
            {
              text: '字段加解密',
              link: '/annotation/CipherField'
            },
            {
              text: '验证是否class的字段',
              link: '/annotation/FieldName'
            },
            {
              text: '服务调用不鉴权注解',
              link: '/annotation/IgnoringAuthentication'
            }
          ]
        }
      ]
    }
  ]
}
const sidebarElsfsAdmin: DefaultTheme.SidebarItem = {
  base: '/elsfsCloud',
  items: []
}
const tutorialMermaid: DefaultTheme.SidebarItem = {
  base: '/tutorial/mermaid/',
  items: [
    {
      text: 'mermaid使用文档',
      base: `/tutorial/mermaid`,
      items: [
        {
          text: '使用',
          link: '/usage'
        },
        {
          text: '基本的语法',
          link: '/flowchart'
        },
        {
          text: '序列图',
          link: '/sequenceDiagram'
        },
        {
          text: '甘特图',
          link: '/gantt'
        },
        {
          text: '例子',
          link: 'demos'
        }
      ]
    }
  ]
}

interface SidebarMix {
  [path: string]: DefaultTheme.SidebarItem
}

const tutorialSecurity: SidebarMix = {
  'security': {
    text: 'spring-security教程',
    base: `/tutorial/security/spring-security/`,
    items: [
      {
        text: '课程介绍',
        link: '/introduce'
      },
      {
        text: '基本使用',
        link: '/base-usage'
      },
      {
        text: 'acl',
        link: '/acl'
      }
    ]
  },
  'oauth2':
    {
      text: '测试',
      base: `/tutorial/security/oauth2-authorization-server`,
      items: [
        {
          text: '课程介绍',
          link: '/index'
        }
      ]
    },
  'jose': {
    text: 'jose',
    base: `/tutorial/security/jose`,
    items: [
      {
        text: '0.jose概况',
        link: '/0.jose概况'
      },
      {
        text: 'jwt',
        link: '/jwt'
      },
      {
        text: 'jwa',
        link: '/jwa'
      },
      {
        text: 'jwe',
        link: '/jwe'
      },
      {
        text: 'jws',
        link: '/jws'
      }
    ]
  }
}
const distributed: SidebarMix = {
  'jta': {
    text: '分布式事务',
    base: `/tutorial/distributed/`,
    items: [
      {
        text: 'jta',
        link: '/jta'
      }
    ]
  },
  'docker': {
    text: 'docker',
    base: `/tutorial/distributed/docker/`,
    items: [
      {
        items: [
          {
            text: 'ps',
            link: '/index'
          }
        ]
      }
    ]
  }
}
const specification: DefaultTheme.SidebarItem = {
  text: 'java',
  base: '/specification',
  items: [
    {
      text: 'java代码风格规范',
      link: '/java/codeStyle'
    },
    {
      text: '强制规范',
      link: '/java/codeSpecification'
    }
    ,   {
      text: '数据库规范',
      link: '/database'
    },
    {
      text: '前端规范',
      link: '/frontEnd'
    },
    {
      text: " <a href='https://semver.org/lang/zh-CN/' target='_blank' rel='noopener noreferrer'>版本规范</a>",
      link: "https://semver.org/lang/zh-CN/",
      target: '_blank',
      rel: 'noopener noreferrer'
    },
    {
      text: '其他规范',
      link: '/other'
    }
  ]



}

/**
 * 侧边栏
 */
export function sidebar(): DefaultTheme.Sidebar {
  return {
    '/elsfsCloud/': elsfsCloud,
    '/elsfsAdmin/': sidebarElsfsAdmin,
    '/tutorial/mermaid': tutorialMermaid,
    '/tutorial/security/spring-security/': tutorialSecurity.security,
    '/tutorial/security/oauth2-authorization-server': tutorialSecurity.oauth2,
    '/tutorial/security/jose': tutorialSecurity.jose,

    '/tutorial/distributed/': distributed.jta,
    '/tutorial/distributed/docker': distributed.docker,
    '/specification/': specification
  }
}


